package com.jurassic.demo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @Author pan_jin
 * @Description: $
 * @Date: 2022/7/15 10:03
 * @Version: 1.0.0
 * @Slogan: 梦想还是要有的万一实现了呢
 */
@Component
public class DatabaseInitializer {
    @Autowired
    JdbcTemplate jdbcTemplate;

    @PostConstruct
    void init() {
        jdbcTemplate.update("CREATE TABLE IF NOT EXISTS users ("
                + "id BIGINT IDENTITY NOT NULL PRIMARY KEY, " +
                "email VARCHAR(100) NOT NULL, "
                + "password VARCHAR(100)NOT NULL, "
                + "name VARCHAR(100)NOT NULL, "
                + "UNIQUE(email)) ");
    }

}
